<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>帖子详情页</title>
    <style type="text/css">
        #container {
            width: 1000px;
            border: solid 2px green;
            margin: 50px auto;
            padding: 30px;
        }
    </style>
</head>
<body>
<div id="container">
    <div>标题：<span th:text="${ post.title }"></span></div>
    <div>类别：<span th:text="${ post.type.desc }"></span></div>
    <div>作者：<span th:text="${ post.user.nickname }"></span></div>
    <div>时间：<span th:text="${ #dates.format(post.createTime, 'yyyy年MM月dd日 HH点mm分ss秒') }"></span></div>
    <hr>
    <div style="width: 94%;border: solid 1px gray;padding: 3%" th:utext="${ post.content }"></div>
    <hr>
    <div>评论：</div>
    <form th:action="@{ /comment/add(postId=${ post.id }) }" method="post" th:if="${ session.onlineUser != null }">
        <textarea rows="5" cols="50" name="content" th:text="${ comment.content }"></textarea>
        <br>
        <input type="submit" value="发表评论">
        <br>
        <span style="color:red" th:text="${ message }"></span>
    </form>

    <a th:href="@{ /user/login }" th:if="${ session.onlineUser == null }">登陆后才可评论！</a>

    <hr/>

    <div th:if="${ #lists.isEmpty(post.comments) }">
        <span>暂无评论！</span>
    </div>

    <div th:if="${ !#lists.isEmpty(post.comments) }" th:each="comment : ${ post.comments }">
        <span th:text="${ commentStat.count }"></span>.
        <span th:text="${ comment.user.nickname }"></span>：
        <span th:text="${ comment.content }"></span>（
        <span th:text="${ #dates.format(comment.createTime, 'yyyy-MM-dd HH:mm:ss') }"></span>）
    </div>

</div>
</body>
</html>